/*
 * @Author: zhangwenbangde@163.com
 * @Date: 2019-04-18 16:45:53
 * */
import Vue from 'vue'
import VueRouter from 'vue-router'
import {
  routerMode
} from '@/env'
import { Resource } from '@/services/resource';
import LocalStorage from '@/services/storage';

import Home from '@/views/home/home.vue'
import Equity from '@/views/equity/equity.vue'
import Login from '@/views/login/login.vue'
import moreInformation from '@/views/login/moreInformation.vue'
import Index from '@/views/index/index.vue'
import mainpage from '@/views/mainpage/mainpage.vue'
import BespeakJhdj from '@/views/bespeakJhdj/bespeakJhdj.vue'
import airportVipForm from '@/views/airportVip/formSubmit/formSubmit.vue'
import airportVipTerms from '@/views/airportVip/formSubmit/terms.vue'
import airportVipServiceArea from '@/views/airportVip/formSubmit/serviceArea.vue'
import airportParkingServiceArea from '@/views/airportParking/formSubmit/serviceArea.vue'
import drinkDrivingServiceArea from '@/views/drinkDriving/formSubmit/serviceArea.vue'
import roadAssistanceServiceArea from '@/views/roadAssistance/formSubmit/serviceArea.vue'
import airportList from '@/views/airportVip/formSubmit/airportList.vue'
import airportParkingList from '@/views/airportParking/formSubmit/airportList.vue'
import airportVipRoomList from '@/views/airportVip/formSubmit/vipRoomList.vue'
import airportParkingForm from '@/views/airportParking/formSubmit/formSubmit.vue'
import airportParkingTerms from '@/views/airportParking/formSubmit/terms.vue'
import trainVipForm from '@/views/trainVip/formSubmit/formSubmit.vue'
import trainVipTerms from '@/views/trainVip/formSubmit/terms.vue'
import trainList from '@/views/trainVip/formSubmit/trainList.vue'
import trainServiceArea from '@/views/trainVip/formSubmit/serviceArea.vue'
import stationVipRoomList from '@/views/trainVip/formSubmit/vipRoomList.vue'
import drinkDrivingForm from '@/views/drinkDriving/formSubmit/formSubmit.vue'
import drinkDrivingModify from '@/views/drinkDriving/formSubmit/modify.vue'


import drinkDrivingTerms from '@/views/drinkDriving/formSubmit/terms.vue'
import drinkDrivingTermsM from '@/views/drinkDriving/formSubmit/termsM.vue'
import roadAssistanceForm from '@/views/roadAssistance/formSubmit/formSubmit.vue'
import roadAssistanceTerms from '@/views/roadAssistance/formSubmit/terms.vue'
import washCarForm from '@/views/washCar/formSubmit/formSubmit.vue'
import washCarTerms from '@/views/washCar/formSubmit/terms.vue'
import userRights from '@/views/personalCenter/userRights.vue'
import order from '@/views/personalCenter/order/order.vue'
import orderRules from '@/views/personalCenter/order/orderRules.vue'
import ticketCode from '@/views/personalCenter/ticketCode/ticketCode.vue'
import personal from '@/views/personalCenter/personal/personal.vue'
import City from '@/views/city/city.vue'
import Point from '@/views/point/point.vue'


Vue.use(VueRouter);
const routes = new VueRouter({
  mode: routerMode,
  routes: [{
  path: '/',
  name: 'home',
  component: Home
}, {
  path: '/equity',
  name: 'equity',
  // meta: {
  //   requireAuth: true // 添加该字段，表示进入这个路由是需要登录的
  // },
  component: Equity
}, {
  path: '/login',
  name: 'login',
  component: Login
}, {
  path: '/moreInformation',
  name: 'moreInformation',
  component: moreInformation
}, {
  path: '/mainpage',
  name: 'mainpage',
  component: mainpage
}, {
  path: '/index',
  name: 'index',
  component: Index
}, {
  path: '/bespeakJhdj',
  name: 'bespeakJhdj',
  component: BespeakJhdj // 酒后代驾
}, {
  path: '/airportVipForm',
  name: 'airportVipForm',
  component: airportVipForm // 
}, {
  path: '/airportVipTerms',
  name: 'airportVipTerms',
  component: airportVipTerms //
},{
  path: '/airportVipServiceArea',
  name: 'airportVipServiceArea',
  component: airportVipServiceArea //
}, {
  path: '/airportList',
  name: 'airportList',
  component: airportList //
}, {
  path: '/airportVipRoomList',
  name: 'airportVipRoomList',
  component: airportVipRoomList //
}, {
  path: '/trainVipForm',
  name: 'trainVipForm',
  component: trainVipForm // 
}, {
  path: '/trainVipTerms',
  name: 'trainVipTerms',
  component: trainVipTerms //
}, {
  path: '/trainList',
  name: 'trainList',
  component: trainList //
},{
  path: '/trainServiceArea',
  name: 'trainServiceArea',
  component: trainServiceArea //
},{
  path: '/stationVipRoomList',
  name: 'stationVipRoomList',
  component: stationVipRoomList //
}, {
  path: '/airportParkingForm',
  name: 'airportParkingForm',
  component: airportParkingForm // 
}, {
  path: '/airportParkingTerms',
  name: 'airportParkingTerms',
  component: airportParkingTerms //
}, {
  path: '/airportParkingList',
  name: 'airportParkingList',
  component: airportParkingList //
}, {
  path: '/airportParkingServiceArea',
  name: 'airportParkingServiceArea',
  component: airportParkingServiceArea //
}, {
  path: '/drinkDrivingForm',
  name: 'drinkDrivingForm',
  component: drinkDrivingForm // 
}, {
  path: '/drinkDrivingModify',
  name: 'drinkDrivingModify',
  component: drinkDrivingModify // 
}, {
  path: '/drinkDrivingTerms',
  name: 'drinkDrivingTerms',
  component: drinkDrivingTerms //
}, {
  path: '/drinkDrivingTermsM',
  name: 'drinkDrivingTermsM',
  component: drinkDrivingTermsM //
}, {
  path: '/drinkDrivingServiceArea',
  name: 'drinkDrivingServiceArea',
  component: drinkDrivingServiceArea //
}, {
  path: '/roadAssistanceForm',
  name: 'roadAssistanceForm',
  component: roadAssistanceForm // 
}, {
  path: '/roadAssistanceTerms',
  name: 'roadAssistanceTerms',
  component: roadAssistanceTerms //
}, {
  path: '/roadAssistanceServiceArea',
  name: 'roadAssistanceServiceArea',
  component: roadAssistanceServiceArea //
}, {
  path: '/washCarForm',
  name: 'washCarForm',
  component: washCarForm // 
}, {
  path: '/washCarTerms',
  name: 'washCarTerms',
  component: washCarTerms //
}, {
  path: '/userRights',
  name: 'userRights',
  component: userRights // 用户权益
}, {
  path: '/personal',
  name: 'personal',
  component: personal // 个人中心
}, {
  path: '/order',
  name: 'order',
  component: order // 我的订单
}, {
  path: '/orderRules',
  name: 'orderRules',
  component: orderRules // 我的订单
}, {
  path: '/ticketCode',
  name: 'ticketCode',
  component: ticketCode // 用户券码
}, {
  path: '/city',
  name: 'city',
  component: City 
}, {
  path: '/point',
  name: 'point',
  component: Point 
}]})


// routes.beforeEach((to, from, next) => {

//   if(to.matched.some((item) => item.meta.login)){
//     // 如果是需要登录的，执行....
//     let info = JSON.parse(localStorage.getItem('userWhether'));
//     if(info === 200){  // 已经登录
//         next()
//     }else{
//       routes.push({
//         path: '/noPermission',
//         query: {
//           redirect: to.path.slice(1)
//         }
//       })
//     }

//     let loginStatus = LocalStorage.getLocalStorage('loginStatus');
//     if(loginStatus){
//       Resource.removeLogin
//         .post({}, { matrixContent: loginStatus})
//         .then(res => {
//           if (res.head.resultCode == 'SUCCESS') { // 已发送
//             let token = res.head.token;
//             LocalStorage.setLocalStorage('token', token, 90 * 24 * 60 * 60 * 1000);
//           }
//         })
//         .catch(err => {
//           console.log(err);
//         });
//     }
//   }else{
//     next()
//   }
// });


export default routes

